import { useAxios } from '@/hooks/web/useAxios'
import { Layout, getParentLayout } from '@/utils/routerHelper'
const request = useAxios()

export const loginApi = (data) => {
  // return request.post({
  //   url: '/user/login',
  //   data
  // })
  return new Promise((resolve) => {
    resolve({
      data: {
        password: 'admin',
        username: 'admin',
        roleId: '1',
        role: 'admin'
      },
      code: '0000'
    })
  })
}

export const loginOutApi = () => {
  // return request.get({ url: '/user/loginOut' })
  return new Promise((resolve) => {
    resolve({ code: '0000', data: null })
  })
}

export const getUserListApi = ({ params }) => {
  return request.get({ url: '/user/list', params })
}

export const getAdminRoleApi = ({ params }) => {
  // return request.get({ url: '/role/list', params })
  return new Promise((resolve) => {
    resolve({
      code: '0000',
      data: {
        list: [
          {
            path: '/level',
            component: Layout,
            redirect: '/level/menu1/menu1-1/menu1-1-1',
            name: 'Level',
            meta: {
              title: 'router.level',
              icon: 'carbon:skill-level-advanced'
            },
            children: [
              {
                path: 'menu1',
                name: 'Menu1',
                component: getParentLayout(),
                redirect: '/level/menu1/menu1-1/menu1-1-1',
                meta: {
                  title: 'router.menu1'
                },
                children: [
                  {
                    path: 'menu1-1',
                    name: 'Menu11',
                    component: getParentLayout(),
                    redirect: '/level/menu1/menu1-1/menu1-1-1',
                    meta: {
                      title: 'router.menu11',
                      alwaysShow: true
                    },
                    children: [
                      {
                        path: 'menu1-1-1',
                        name: 'Menu111',
                        component: () => import('@/views/Level/Menu111.vue'),
                        meta: {
                          title: 'router.menu111'
                        }
                      }
                    ]
                  },
                  {
                    path: 'menu1-2',
                    name: 'Menu12',
                    component: () => import('@/views/Level/Menu12.vue'),
                    meta: {
                      title: 'router.menu12'
                    }
                  }
                ]
              },
              {
                path: 'menu2',
                name: 'Menu2Demo',
                component: () => import('@/views/Level/Menu2.vue'),
                meta: {
                  title: 'router.menu2'
                }
              }
            ]
          }
        ]
      }
    })
  })
}

export const getTestRoleApi = ({ params }) => {
  return request.get({ url: '/role/list', params })
}
